package cn.yunhe.servlet;

import cn.yunhe.dao.IAdminDao;
import cn.yunhe.dao.impl.AdminDao;
import cn.yunhe.service.RegService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class CheckNameServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        PrintWriter out = response.getWriter();
        String username = request.getParameter("username");
        RegService regService = new RegService();

        //判断是否有重名
        if (regService.getAdmin(username)) {
            out.print("true");
        } else{
            out.print("false");
        }

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
